import { defineStore } from "pinia";
import { getCurrentUser, getSomeShmetroConfig } from "../request/system";
import GLOBAL from "../utils/globelConfig";
import type { ISystemConfig } from "./storeType";

export const useSystemrStore = defineStore("system", {
  state: () => ({
    buffer: {
      stationList: sessionStorage.getItem("stationList"),
    } as any, //cache data
    notConfirmedState: [
      {
        line_name: "13号线",
        train_type: "13A01",
        train_no: "1323",
        fault_code: "CCF_68",
        fault_time: "1757309298252",
        fault_system: "CCF",
        fault_name: "ATP紧急制动",
        fault_level: "1",
        fault_cause: null,
        train_place: "Tc2",
        end_time: null,
        fault_alias: "c_p01D1_133_3",
        is_send: "0",
        is_serious: "2",
        current_stationid: "28",
        terminate_stationid: "31",
        solution: null,
        maintenance_tips: null,
        fault_status: null,
        set_serious_time: null,
        set_serious_user: null,
        line_code: null,
        next_stationid: "29",
        put_into_states: "inLine",
        set_serious_reason: null,
        insert_time: "1757309054060",
        fault_type: "normal",
        speed: "56.02",
        run_mode: "ATO模式",
        driver_activator: "Tc2",
        control_mode: "无",
      },
      {
        line_name: "1号线",
        train_type: "01A05",
        train_no: "01051",
        fault_code: "msg2_654",
        fault_time: "1757309291768",
        fault_system: "msg2",
        fault_name: "M2车_3B门严重故障(6门)",
        fault_level: "3",
        fault_cause: null,
        train_place: "-",
        end_time: null,
        fault_alias: "c_p000C_81_3",
        is_send: "0",
        is_serious: "2",
        current_stationid: "0",
        terminate_stationid: "0",
        solution: null,
        maintenance_tips: null,
        fault_status: null,
        set_serious_time: null,
        set_serious_user: null,
        line_code: null,
        next_stationid: "0",
        put_into_states: "inLine",
        set_serious_reason: null,
        insert_time: "1757309054164",
        fault_type: "normal",
        speed: "0.00",
        run_mode: "制动",
        driver_activator: "无",
        control_mode: "主控未激活",
      },
      {
        line_name: "13号线",
        train_type: "13A01",
        train_no: "1323",
        fault_code: "CCF_68",
        fault_time: "1757309290729",
        fault_system: "CCF",
        fault_name: "ATP紧急制动",
        fault_level: "1",
        fault_cause: null,
        train_place: "Tc1",
        end_time: null,
        fault_alias: "c_p01D1_8_3",
        is_send: "0",
        is_serious: "2",
        current_stationid: "28",
        terminate_stationid: "31",
        solution: null,
        maintenance_tips: null,
        fault_status: null,
        set_serious_time: null,
        set_serious_user: null,
        line_code: null,
        next_stationid: "29",
        put_into_states: "inLine",
        set_serious_reason: null,
        insert_time: "1757309047374",
        fault_type: "normal",
        speed: "55.68",
        run_mode: "ATO模式",
        driver_activator: "Tc2",
        control_mode: "无",
      },
    ], //接口：/faultManage/getFaultList，定时跟新 todo
    station: JSON.parse(sessionStorage.getItem("station") as string) || {},
    lineGpsMap:
      JSON.parse(sessionStorage.getItem("lineGpsMap") as string) || {},
    selectedMap:
      JSON.parse(sessionStorage.getItem("selectedMap") as string) || {},
    showOp: false, //true为只展示,
    setIntervalArr: [] as number[],
    nowPage:"",
  }),
  actions: {
    setShowOp(isShow: boolean) {
      this.showOp = isShow;
    },
  },
});
